var mDCal;
var toDay;
	//	오늘날짜 가져옴
	toDay = toTimeString(new Date());
	// 달력 생성
	function createCalendar(){
		dhtmlx.skin = "";
		mDCal = new dhtmlxDblCalendarObject('dhtmlxDblCalendar', false, {
			isMonthEditable: true,
			isYearEditable: true
		});
		mDCal.leftCalendar.setOnClickHandler(setStdt);
		mDCal.rightCalendar.setOnClickHandler(setEndt);
		mDCal.setYearsRange(2000, 2200);
		mDCal.setDateFormat("%d-%m-%Y");
		mDCal.setDate(toDay, toDay);
		mDCal.draw();
		dhtmlx.skin = "dhx_skyblue";
		$('#dhtmlxDblCalendar').hide();
	}
	
	function createCalendar1(){
		dhtmlx.skin = "";
		mDCal = new dhtmlxDblCalendarObject('dhtmlxDblCalendar1', false, {
			isMonthEditable: true,
			isYearEditable: true
		});
		mDCal.leftCalendar.setOnClickHandler(setReqFdate);
		mDCal.rightCalendar.setOnClickHandler(setReqTdate);
		mDCal.setYearsRange(2000, 2200);
		mDCal.setDateFormat("%d-%m-%Y");
		mDCal.setDate(toDay, toDay);
		mDCal.draw();
		dhtmlx.skin = "dhx_skyblue";
		$('#dhtmlxDblCalendar1').hide();
	}
	
	function createCalendar2(){
		dhtmlx.skin = "";
		mDCal = new dhtmlxDblCalendarObject('dhtmlxDblCalendar2', false, {
			isMonthEditable: true,
			isYearEditable: true
		});
		mDCal.leftCalendar.setOnClickHandler(setReviewFdate);
		mDCal.rightCalendar.setOnClickHandler(setReviewTdate);
		mDCal.setYearsRange(2000, 2200);
		mDCal.setDateFormat("%d-%m-%Y");
		mDCal.setDate(toDay, toDay);
		mDCal.draw();
		dhtmlx.skin = "dhx_skyblue";
		$('#dhtmlxDblCalendar2').hide();
	}
	
	function createCalendar3(){
		dhtmlx.skin = "";
		mDCal = new dhtmlxDblCalendarObject('dhtmlxDblCalendar3', false, {
			isMonthEditable: true,
			isYearEditable: true
		});
		mDCal.leftCalendar.setOnClickHandler(setWinDate);
		mDCal.rightCalendar.setOnClickHandler(setProvideDate);
		mDCal.setYearsRange(2000, 2200);
		mDCal.setDateFormat("%d-%m-%Y");
		mDCal.setDate(toDay, toDay);
		mDCal.draw();
		dhtmlx.skin = "dhx_skyblue";
		$('#dhtmlxDblCalendar3').hide();
	}
	    
	    
	// 왼쪽 달력 날짜 클릭시 값 세팅
    function setStdt(date){
   		$('#srchStdt').val(toTimeString(date));
    }
    
    function setReqFdate(date){
    	$('#reqFdate').val(toTimeString(date));
    }
    
    function setReviewFdate(date){
    	$('#reviewFdate').val(toTimeString(date));
    }
    
    function setWinDate(date){
    	$('#winDate').val(toTimeString(date));
    }

    // 오른쪽 달력 날짜 클릭시 값 세팅    
    function setEndt(date){
   		$('#srchEndt').val(toTimeString(date));
    }
    
    function setReqTdate(date){
    	$('#reqTdate').val(toTimeString(date));
    }
    
    function setReviewTdate(date){
    	$('#reviewTdate').val(toTimeString(date));
    }
    
    function setProvideDate(date){
    	$('#provideDate').val(toTimeString(date));
    }
    
    // 날짜 변환
    function toTimeString(date) { //formatTime(date)
        var year  = date.getFullYear();
        var month = date.getMonth() + 1; // 1월=0,12월=11이므로 1 더함
        var day   = date.getDate();
        var hour  = date.getHours();
        var min   = date.getMinutes();

        if (("" + month).length == 1) { month = "0" + month; }
        if (("" + day).length   == 1) { day   = "0" + day;   }
        if (("" + hour).length  == 1) { hour  = "0" + hour;  }
        if (("" + min).length   == 1) { min   = "0" + min;   }

        return ("" + year + month + day);
    }
